package com.hooper.online.controller;

import com.cameron.utils.Result;
import com.hooper.online.service.StatisticsService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author Tim Hooper
 * @version 1.0
 * @time 2022/11/13/20:40
 */
@CrossOrigin
@RestController
@RequestMapping("/statistic-service")
public class StatisticsController {

    @Resource
    private StatisticsService statisticsService;

    @GetMapping("/count/{date}")
    public Result getRegisterCount(@PathVariable String date) {
        return Result.ok().data("count", statisticsService.statistics(date));
    }

    @GetMapping("/{type}/{start}/{end}")
    public Result getChartData(@PathVariable("end") String end,
                               @PathVariable("start") String start,
                               @PathVariable("type") String type) {
        Map<String, Object> result = statisticsService.queryChartData(type, start, end);
        return Result.ok().data(result);
    }
}
